<?php

namespace Nimo\Bundle\BookstoreApiBundle\Entity\User;

use Doctrine\ORM\Mapping as ORM;

/**
 * Nimo\Bundle\BookstoreApiBundle\Entity\User\User
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="Nimo\Bundle\BookstoreApiBundle\Entity\User\UserRepository")
 */
class User
{
    /**
     * @var integer $id
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string $firstName
     *
     * @ORM\Column(name="first_name", type="string", length=255)
     */
    private $firstName;

    /**
     * @var string $lastName
     *
     * @ORM\Column(name="last_name", type="string", length=255)
     */
    private $lastName;

    /**
     * @var string $username
     *
     * @ORM\Column(name="username", type="string", length=255)
     */
    private $username;

    /**
     * @var string $password
     *
     * @ORM\Column(name="password", type="string", length=255)
     */
    private $password;

    /**
     * @var string $salt
     *
     * @ORM\Column(name="salt", type="string", length=16)
     */
    private $salt;

    /**
     * @var boolean $isActive
     *
     * @ORM\Column(name="is_active", type="boolean")
     */
    private $isActive;

    /**
     * @var string $email
     *
     * @ORM\Column(name="email", type="string", length=255)
     */
    private $email;

    /**
     * @var \DateTime $registeredAt
     *
     * @ORM\Column(name="registered_at", type="datetime")
     */
    private $registeredAt;

    /**
     * @var \DateTime $lastLogin
     *
     * @ORM\Column(name="last_login", type="datetime")
     */
    private $lastLogin;

    /**
     * @var ArrayCollection $reviews
     *
     * @ORM\OneToMany(targetEntity="Review", mappedBy="user")
     */
    protected $reviews;

    /**
     * @var ArrayCollection $view_history
     *
     * @ORM\OneToMany(targetEntity="ViewHistory", mappedBy="user")
     */
    protected $view_history;


    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set firstName
     *
     * @param string $firstName
     * @return User
     */
    public function setFirstName($firstName)
    {
        $this->firstName = $firstName;
    
        return $this;
    }

    /**
     * Get firstName
     *
     * @return string 
     */
    public function getFirstName()
    {
        return $this->firstName;
    }

    /**
     * Set lastName
     *
     * @param string $lastName
     * @return User
     */
    public function setLastName($lastName)
    {
        $this->lastName = $lastName;
    
        return $this;
    }

    /**
     * Get lastName
     *
     * @return string 
     */
    public function getLastName()
    {
        return $this->lastName;
    }

    /**
     * Set username
     *
     * @param string $username
     * @return User
     */
    public function setUsername($username)
    {
        $this->username = $username;
    
        return $this;
    }

    /**
     * Get username
     *
     * @return string 
     */
    public function getUsername()
    {
        return $this->username;
    }

    /**
     * Set password
     *
     * @param string $password
     * @return User
     */
    public function setPassword($password)
    {
        $this->password = $password;
    
        return $this;
    }

    /**
     * Get password
     *
     * @return string 
     */
    public function getPassword()
    {
        return $this->password;
    }

    /**
     * Set salt
     *
     * @param string $salt
     * @return User
     */
    public function setSalt($salt)
    {
        $this->salt = $salt;
    
        return $this;
    }

    /**
     * Get salt
     *
     * @return string 
     */
    public function getSalt()
    {
        return $this->salt;
    }

    /**
     * Set isActive
     *
     * @param boolean $isActive
     * @return User
     */
    public function setIsActive($isActive)
    {
        $this->isActive = $isActive;

        return $this;
    }

    /**
     * Enable user account
     *
     * @return User
     */
    public function setAsActive()
    {
        return $this->setIsActive(true);
    }

    /**
     * Disable user account
     *
     * @return User
     */
    public function setAsInactive()
    {
        return $this->setIsActive(false);
    }

    /**
     * Get isActive
     *
     * @return boolean 
     */
    public function isActive()
    {
        return $this->isActive;
    }

    /**
     * Set email
     *
     * @param string $email
     * @return User
     */
    public function setEmail($email)
    {
        $this->email = $email;
    
        return $this;
    }

    /**
     * Get email
     *
     * @return string 
     */
    public function getEmail()
    {
        return $this->email;
    }

    /**
     * Set registeredAt
     *
     * @param \DateTime $registeredAt
     * @return User
     */
    public function setRegisteredAt($registeredAt)
    {
        $this->registeredAt = $registeredAt;
    
        return $this;
    }

    /**
     * Get registeredAt
     *
     * @return \DateTime 
     */
    public function getRegisteredAt()
    {
        return $this->registeredAt;
    }

    /**
     * Set lastLogin
     *
     * @param \DateTime $lastLogin
     * @return User
     */
    public function setLastLogin($lastLogin)
    {
        $this->lastLogin = $lastLogin;
    
        return $this;
    }

    /**
     * Get lastLogin
     *
     * @return \DateTime 
     */
    public function getLastLogin()
    {
        return $this->lastLogin;
    }

    /**
     * Get isActive
     *
     * @return boolean 
     */
    public function getIsActive()
    {
        return $this->isActive;
    }
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->reviews = new \Doctrine\Common\Collections\ArrayCollection();
        $this->view_history = new \Doctrine\Common\Collections\ArrayCollection();
    }
    
    /**
     * Add reviews
     *
     * @param Nimo\Bundle\BookstoreApiBundle\Entity\User\Review $reviews
     * @return User
     */
    public function addReview(\Nimo\Bundle\BookstoreApiBundle\Entity\User\Review $reviews)
    {
        $this->reviews[] = $reviews;
    
        return $this;
    }

    /**
     * Remove reviews
     *
     * @param Nimo\Bundle\BookstoreApiBundle\Entity\User\Review $reviews
     */
    public function removeReview(\Nimo\Bundle\BookstoreApiBundle\Entity\User\Review $reviews)
    {
        $this->reviews->removeElement($reviews);
    }

    /**
     * Get reviews
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getReviews()
    {
        return $this->reviews;
    }

    /**
     * Add view_history
     *
     * @param Nimo\Bundle\BookstoreApiBundle\Entity\User\ViewHistory $viewHistory
     * @return User
     */
    public function addViewHistory(\Nimo\Bundle\BookstoreApiBundle\Entity\User\ViewHistory $viewHistory)
    {
        $this->view_history[] = $viewHistory;
    
        return $this;
    }

    /**
     * Remove view_history
     *
     * @param Nimo\Bundle\BookstoreApiBundle\Entity\User\ViewHistory $viewHistory
     */
    public function removeViewHistory(\Nimo\Bundle\BookstoreApiBundle\Entity\User\ViewHistory $viewHistory)
    {
        $this->view_history->removeElement($viewHistory);
    }

    /**
     * Get view_history
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getViewHistory()
    {
        return $this->view_history;
    }
}